package com.example.web;


import com.example.fanqie.entity.Chapter;
import com.example.fanqie.mapper.ChapterMapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ChapterDao {

    @Resource
    private ChapterMapper chapterMapper;

    @RequestMapping("/selectChapter")
    public List<Chapter> selectchapter(@RequestParam("novelId") Integer novelId){
        List<Chapter> chapters = chapterMapper.selectchapterlist(novelId);
        return chapters;

    }



    @RequestMapping("/selectChap")
    public Chapter selectChap(@RequestBody Chapter chapter){

        Chapter chapter1 = chapterMapper.selectBychapterId(chapter.getChapterId());

        return  chapter1;

    }

    @RequestMapping("/insertChapter")
    public int insertChapter(@RequestBody Chapter chapter){
        int result = chapterMapper.insert(chapter);
        return result;

    }


    @RequestMapping("/updateChapter")
    public int updateChapter(@RequestBody Chapter chapter) {
        int result = chapterMapper.updateById(chapter);
        return result;
    }





}
